package osSRC.schedule;
class RoundRobinPCB extends PCB {
	private int round;
	public RoundRobinPCB(String processName, int priority, int needTime) {
		super(processName,needTime);
		this.priority = priority;
		this.round=0;
		this.state = "W";
	}

	@Override
	public String toString() {
		return super.toString()
				+ RoundRobinScheduler.getRound()+"\t\t"
				+this.round;
	}
	int call(int timeSlice){
		int res;
		if(this.needTime>=timeSlice) {
			res=timeSlice;
			this.state="R";
			this.CPU_Time +=timeSlice;
			this.needTime-=timeSlice;
			this.round++;
		}
		else if(this.needTime>0){
			res=this.needTime;
			this.state="R";
			this.CPU_Time +=this.needTime;
			this.needTime=0;
			this.round++;
		}
		else return 0;
		return res;
	}
}
